package org.csu.jpetstore_users_backend_pj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.csu.jpetstore_users_backend_pj.entity.Order;
import org.csu.jpetstore_users_backend_pj.mapper.OrderMapper;
import org.csu.jpetstore_users_backend_pj.service.OrderService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("orderService")
@MapperScan("org.csu.petstore.mapper")
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;
    @Override
    public void addOrder(Order newOrder) {
        newOrder.setStatus("0");
        orderMapper.insert(newOrder);

    }

    @Override
    public int getOrderID(Order order) {
        //return this.orderDao.getOrderID(order);
        return 1;
    }
    @Override
    public List<Order> getOrdersByName(String username){
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return orderMapper.selectList(queryWrapper);
    }
}
